As a type of short-distance communication network, a communication network conforming to the Wi-Fi Direct specification has been known (see Non-Patent Document 1, for example). In this type of communication network, among a plurality of communication devices participating in a certain network, one of the communication devices functions as a master (a group owner) having an access point function, and the remaining communication devices function as slaves (clients) of the master. Compared with a Wi-Fi Ad-hoc network in which only one-to-one connection is available, a communication network conforming to the Wi-Fi Direct specification has features such as one-to-many connection is available, communication between the slaves can be established via the master, and the strength of security is relatively high. Thus, in recent years, a communication network conforming to the Wi-Fi Direct specification has been used in various applications such as data sharing. The present invention relates to a method for configuring such a communication network conforming to the Wi-Fi Direct specification. However, application of the present invention is not limited to a communication network conforming to the Wi-Fi Direct specification.
Patent Document 1 describes an exemplary method for configuring a communication network conforming to the Wi-Fi Direct specification. In Patent Document 1, a communication device intending to form a communication network first searches the surroundings thereof for another communication device which is to be a connection destination. When finding another communication device in the search, the communication device then performs group owner negotiation with the other communication device and determines the master (the group owner). After determination of the master, through a predetermined connection procedure, the communication device and the other communication device connect to each other and configure a communication network. Moreover, in Patent Document 1, in the group owner negotiation with the other communication device, the communication device determines whether or not exchange of information with the other communication device has succeeded, on the basis of a response signal transmitted from the other communication device. In the case of determining that the exchange of information has failed, the communication device determines whether or not to automatically change the setting depending on the cause of the failure. When determining to automatically change the setting, the communication device automatically changes the setting, and performs group owner negotiation with the other communication device again in accordance with the changed setting.    Patent Document 1: Japanese Unexamined Patent Application Publication No. JP-A 2012-129898    Non-Patent Document 1: Wi-Fi Alliance Technical Committee P2P Task Group Wi-Fi Peer-to-Peer (P2P) Technical Specification Version 1.1
The technique described in Patent Document 1 is to, for a counterpart communication device that the local communication device has failed to perform group owner negotiation, change the setting and performing group owner negotiation again, and the technique is premised on that there is a possibility of success in group owner negotiation when the setting is changed. However, when the failure is not caused by the local communication device but is caused by the counterpart communication device, there is no guarantee of success in group owner negotiation how the setting of the local communication device is changed. Thus, actually, it is general, in a case where the number of trials has reached a predetermined number of times, to abandon connection to the other communication device without trying group owner negotiation any more. The above example shows a case where connection to another communication device fails because of a failure in group owner negotiation. However, a failure in connection may occur not only in group owner negotiation for determining the master but also in another connection phase.
When a communication device intending to form a communication network fails in connection to another communication device for any reason, the communication device again searches for another communication device existing therearound. At this time, in a case where the other communication device which the local communication device has found in the last search and failed to connect to still exists around the local communication device, the other communication device found last time may be first found even if still another communication device exists. Then, the communication device again executes the process for connecting to the found other communication device. This is because there is no way to check that the currently found communication device is the communication device having been found previously and having failed in the connection process. As a result, the connection process fails again. In other words, there is a problem as described below: in a case where another communication device with problem and another communication device without problem exist around the local communication device and the other communication device with problem is first found every time a process of searching for another communication device is executed, a process that the other communication device with problem is found, connection is tried in vain, the other communication device with problem is found again and connection is tried in vain is repeated in spite of the presence of the communication device without problem around the local device, and the local device cannot connect forever to the connection device without problem.